package com.soilflow.web.controller.dahu.web;

import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.DahuRecruit;
import com.soilflow.common.enums.BusinessType;
import com.soilflow.common.utils.poi.ExcelUtil;
import com.soilflow.info.service.IDahuRecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【招聘】Controller
 * 
 * @author party
 * @date 2023-11-02
 */
@RestController
@RequestMapping("/reception/recruit")
public class RecruitController extends BaseController {
    @Autowired
    private IDahuRecruitService dahuRecruitService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:recruit:list')")
    @GetMapping("/list")
    public TableDataInfo list(DahuRecruit dahuRecruit) {
        startPage();
        List<DahuRecruit> list = dahuRecruitService.selectDahuRecruitList(dahuRecruit);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DahuRecruit dahuRecruit)
    {
        List<DahuRecruit> list = dahuRecruitService.selectDahuRecruitList(dahuRecruit);
        ExcelUtil<DahuRecruit> util = new ExcelUtil<DahuRecruit>(DahuRecruit.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:recruit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dahuRecruitService.selectDahuRecruitById(id));
    }

    /**
     * 新增【发布招聘信息】
     */
//    @PreAuthorize("@ss.hasPermi('system:recruit:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DahuRecruit dahuRecruit)
    {
        return toAjax(dahuRecruitService.insertDahuRecruit(dahuRecruit));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:recruit:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DahuRecruit dahuRecruit)
    {
        return toAjax(dahuRecruitService.updateDahuRecruit(dahuRecruit));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:recruit:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dahuRecruitService.deleteDahuRecruitByIds(ids));
    }
}
